<?php

//Creer un nouvel admin
function modelcreateadmin($bdd,$type_img) {
   if ($type_img != 3) {
    $req = $bdd->prepare('INSERT INTO users(id_user_type, user_login, user_description, user_email, user_password, user_job, user_name, user_surname,img_type) 
        VALUES(:user_type, :user_login, :user_description, :user_email, :user_password,:user_job,:user_name,:user_surname,:img_type)');
    $req->execute(array(
        'user_type' =>  2 ,
        'user_login' =>  $_POST['login'] ,
        'user_description' => $_POST['description'],
        'user_email' =>  $_POST['email'],
        'user_password' =>  sha1($_POST['password']),
           'user_job' => $_POST['job'],
         'user_name'=>  $_POST['name'], 
         'user_surname'=>  $_POST['surname'] ,
           'img_type'=>   $type_img
    ));}
    else
    {$req = $bdd->prepare('INSERT INTO users(id_user_type, user_login, user_description, user_email, user_password, user_job, user_name, user_surname) 
        VALUES(:user_type, :user_login, :user_description, :user_email, :user_password,:user_job,:user_name,:user_surname)');
    $req->execute(array(
        'user_type' =>  2 ,
        'user_login' =>  $_POST['login'] ,
        'user_description' => $_POST['description'],
        'user_email' =>  $_POST['email'],
        'user_password' =>  sha1($_POST['password']),
           'user_job' => $_POST['job'],
         'user_name'=>  $_POST['name'], 
         'user_surname'=>  $_POST['surname'])); }
}
    
function select_last_id($bdd) {
    $results = $bdd->query('  SELECT id_user
FROM users 
ORDER BY id_user DESC 
LIMIT 1
    
     ');
    return $results;
}
function count_work($bdd) {
    $req = $bdd->query('SELECT id_user FROM users');
    $count = $req->rowCount();
    return $count;
}
?>